package com.azt.api.dto;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * 发布商品DTO
 * Created by shangwq on 2017/2/6.
 */
public class ProductData implements Serializable {

    private Integer productId;

    private String productName;

    private String subName;

    private Integer categoryFId;

    private Integer categorySId;

    private Integer categoryTId;

    private Integer brandId;

    private String model;

    private String picPath;

    private String descr;

    private String unit;

    private Integer serviceDuration;

    private String serviceUnit;

    private String service;

    private String attachfile;

    private String attachName;

    private Integer userId;

    private Integer companyId;

    private Integer ifSelf;

    /**
     * sku属性
     * */
    private List<SkuData> skuList = new ArrayList<>();

    public static class SkuData {

        private Integer skuId;

        private Double price;

        private Double memberPrice;

        /**
         * 库存变动数量(正数表示增加库存，负数表示减少库存)
         * */
        private Integer changeStock;

        private List<SkuAttr> skuAttrList = new ArrayList<>();

        public List<SkuAttr> getSkuAttrList() {
            return skuAttrList;
        }

        public void setSkuAttrList(List<SkuAttr> skuAttrList) {
            this.skuAttrList = skuAttrList;
        }

        public Integer getSkuId() {
            return skuId;
        }

        public void setSkuId(Integer skuId) {
            this.skuId = skuId;
        }

        public Double getPrice() {
            return price;
        }

        public void setPrice(Double price) {
            this.price = price;
        }

        public Double getMemberPrice() {
            return memberPrice;
        }

        public void setMemberPrice(Double memberPrice) {
            this.memberPrice = memberPrice;
        }

        public Integer getChangeStock() {
            return changeStock;
        }

        public void setChangeStock(Integer changeStock) {
            this.changeStock = changeStock;
        }

        /**
         * 获取sku属性信息，格式：属性id:值id; ...
         * */
        public String getSkuAttrStr1() {
            StringBuilder skuInfo = null;
            if(getSkuAttrList() != null && getSkuAttrList().size() > 0) {
                skuInfo = new StringBuilder();
                for(SkuAttr skuAttr : getSkuAttrList()) {
                    skuInfo.append(skuAttr.getNameId()).append(":").append(skuAttr.getValueId()).append(";");
                }
                if(skuInfo.toString().endsWith(";")) {
                    skuInfo = skuInfo.deleteCharAt(skuInfo.length() - 1);
                }
            }
            return skuInfo == null ? null : skuInfo.toString();
        }

        /**
         * 获取sku属性信息，格式：属性名称：值名称; ...
         * */
        public String getSkuAttrStr2() {
            StringBuilder skuInfo = null;
            if(getSkuAttrList() != null && getSkuAttrList().size() > 0) {
                skuInfo = new StringBuilder();
                for(SkuAttr skuAttr : getSkuAttrList()) {
                    skuInfo.append(skuAttr.getName()).append(":").append(skuAttr.getValue()).append(";");
                }
                if(skuInfo.toString().endsWith(";")) {
                    skuInfo = skuInfo.deleteCharAt(skuInfo.length() - 1);
                }
            }
            return skuInfo == null ? null : skuInfo.toString();
        }

        public static class SkuAttr {
            private Integer nameId;
            private Integer valueId;
            private String name;
            private String value;

            public Integer getNameId() {
                return nameId;
            }

            public void setNameId(Integer nameId) {
                this.nameId = nameId;
            }

            public Integer getValueId() {
                return valueId;
            }

            public void setValueId(Integer valueId) {
                this.valueId = valueId;
            }

            public String getName() {
                return name;
            }

            public void setName(String name) {
                this.name = name;
            }

            public String getValue() {
                return value;
            }

            public void setValue(String value) {
                this.value = value;
            }
        }
    }

    public Integer getProductId() {
        return productId;
    }

    public void setProductId(Integer productId) {
        this.productId = productId;
    }

    public String getProductName() {
        return productName;
    }

    public void setProductName(String productName) {
        this.productName = productName;
    }

    public String getSubName() {
        return subName;
    }

    public void setSubName(String subName) {
        this.subName = subName;
    }

    public Integer getCategoryFId() {
        return categoryFId;
    }

    public void setCategoryFId(Integer categoryFId) {
        this.categoryFId = categoryFId;
    }

    public Integer getCategorySId() {
        return categorySId;
    }

    public void setCategorySId(Integer categorySId) {
        this.categorySId = categorySId;
    }

    public Integer getCategoryTId() {
        return categoryTId;
    }

    public void setCategoryTId(Integer categoryTId) {
        this.categoryTId = categoryTId;
    }

    public Integer getBrandId() {
        return brandId;
    }

    public void setBrandId(Integer brandId) {
        this.brandId = brandId;
    }

    public String getModel() {
        return model;
    }

    public void setModel(String model) {
        this.model = model;
    }

    public String getPicPath() {
        return picPath;
    }

    public void setPicPath(String picPath) {
        this.picPath = picPath;
    }

    public String getDescr() {
        return descr;
    }

    public void setDescr(String descr) {
        this.descr = descr;
    }

    public Integer getServiceDuration() {
        return serviceDuration;
    }

    public void setServiceDuration(Integer serviceDuration) {
        this.serviceDuration = serviceDuration;
    }

    public String getServiceUnit() {
        return serviceUnit;
    }

    public void setServiceUnit(String serviceUnit) {
        this.serviceUnit = serviceUnit;
    }

    public String getService() {
        return service;
    }

    public void setService(String service) {
        this.service = service;
    }

    public String getUnit() {
        return unit;
    }

    public void setUnit(String unit) {
        this.unit = unit;
    }

    public String getAttachfile() {
        return attachfile;
    }

    public void setAttachfile(String attachfile) {
        this.attachfile = attachfile;
    }

    public Integer getUserId() {
        return userId;
    }

    public void setUserId(Integer userId) {
        this.userId = userId;
    }

    public Integer getCompanyId() {
        return companyId;
    }

    public void setCompanyId(Integer companyId) {
        this.companyId = companyId;
    }

    public String getAttachName() {
        return attachName;
    }

    public void setAttachName(String attachName) {
        this.attachName = attachName;
    }

    public Integer getIfSelf() {
        return ifSelf;
    }

    public void setIfSelf(Integer ifSelf) {
        this.ifSelf = ifSelf;
    }

    public List<SkuData> getSkuList() {
        return skuList;
    }

    public void setSkuList(List<SkuData> skuList) {
        this.skuList = skuList;
    }

}
